#include "../../common/detail.hpp"
#include "../../server/rpc_server.hpp"

void Add(const Json::Value &req, Json::Value &rsp)
{
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;
}

int main()
{
    // 构建desc对象
    auto desc_factory = std::shared_ptr<rpc::server::DescribeFactory>(new rpc::server::DescribeFactory());
    desc_factory->setMethod("Add");
    desc_factory->PushParam("num1", rpc::server::v_type::INT);
    desc_factory->PushParam("num2", rpc::server::v_type::INT);
    desc_factory->setRtype(rpc::server::INT);
    desc_factory->setCallback(Add);

    rpc::server::RpcServer server(rpc::Address("127.0.0.1", 9090), true, rpc::Address("127.0.0.1", 8080));
    server.RegistryMethod(desc_factory->build());
    server.start();
    return 0;
}